package com.xbts.system.domain;

import java.util.Date;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotEmpty;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.Data;
import java.util.Objects;
import javax.validation.constraints.NotNull;
import com.xbts.common.annotation.Excel;
import com.xbts.common.utils.StringUtils;
import com.xbts.common.core.domain.BaseEntity;

/**
 * 导航条内容对象 cn_navigation_bar_content
 *
 * @author xbts
 * @date 2023-12-01
 */
@Data
@ApiModel("导航条内容对象")
@TableName("cn_navigation_bar_content")
public class CnNavigationBarContent extends BaseEntity {

    private static final long serialVersionUID=1L;

    /** id */
    @TableId
    private String id;

    /** 导航条类型ID */
    @Excel(name = "导航条类型ID")
    @ApiModelProperty("导航条类型ID")
    @NotEmpty(message = "导航条类型ID不能为空")
    private String navigationBarTypeId;

    @TableField(exist = false)
    private String navigationBarTypeName;

    /** 排序 */
    @Excel(name = "排序")
    @ApiModelProperty("排序")
    private Integer sort;

    /** 封面地址 */
    @Excel(name = "封面地址")
    @ApiModelProperty("封面地址")
    @NotEmpty(message = "封面地址不能为空")
    private String coverUrl;

    /** 标题 */
    @Excel(name = "标题")
    @ApiModelProperty("标题")
    @NotEmpty(message = "标题不能为空")
    private String title;

    /** 内容 */
    @Excel(name = "内容")
    @ApiModelProperty("内容")
    @NotEmpty(message = "内容不能为空")
    private String content;

    /** 简介 */
    @Excel(name = "简介")
    @ApiModelProperty("简介")
    private String introduction;

    /** 发布时间 */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "发布时间", width = 40, dateFormat = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("发布时间")
    private Date publishTime;

    /** 发布人 */
    @Excel(name = "发布人")
    @ApiModelProperty("发布人")
    private String publisher;

    /** 状态（1展示，2隐藏） */
    @Excel(name = "状态", readConverterExp = "1=展示，2隐藏")
    @ApiModelProperty("状态")
    @NotEmpty(message = "状态不能为空")
    private String status;

    public<T> QueryWrapper<T> queryWrapper(){
        QueryWrapper<T> queryWrapper=new QueryWrapper<>();
        queryWrapper.like(StringUtils.isNotEmpty(navigationBarTypeId),"navigation_bar_type_id",navigationBarTypeId);
        queryWrapper.eq(!Objects.isNull(sort),"sort",sort);
        queryWrapper.like(StringUtils.isNotEmpty(coverUrl),"cover_url",coverUrl);
        queryWrapper.like(StringUtils.isNotEmpty(title),"title",title);
        queryWrapper.like(StringUtils.isNotEmpty(content),"content",content);
        queryWrapper.like(StringUtils.isNotEmpty(introduction),"introduction",introduction);
        queryWrapper.eq(!Objects.isNull(publishTime),"publish_time",publishTime);
        queryWrapper.like(StringUtils.isNotEmpty(publisher),"publisher",publisher);
        queryWrapper.like(StringUtils.isNotEmpty(status),"status",status);
        queryWrapper.orderByAsc("sort");
        queryWrapper.orderByDesc("create_time");
        return queryWrapper;
    }
}